var app = getApp();

Page({
    data: {
        page: 1,
        order_list: [],
        is_show_hf: false,
        pl_state: 1 //2
    },
    GetListF: function(e) {
        var state = e.currentTarget.dataset.state; //获取data-src
        if (state != this.data.pl_state) {
            this.setData({
                pl_state: state,
                order_list: [],
                page: 1,
                mygd: ''
            });
            this.GetStoreAssessList();
        }
    },
    GetStoreAssessList: function(t) {
        var a = this,
            e = wx.getStorageSync("sjdsjid");
        app.util.request({
            url: "entry/wxapp/StoreAssessList",
            cachetime: "0",
            data: {
                store_id: e,
                page: a.data.page,
                state: a.data.pl_state,
                pagesize: 10
            },
            success: function(t) {
                t.data.assess.length > 0 ?
                    a.data.page++ :
                    a.setData({
                        mygd: 1,
                    });

                var list = a.data.order_list;
                list = list.concat(t.data.assess)
                a.setData({
                    order_list: list,
                    store: t.data.store,
                    mygd: 1,
                    storelist: t
                });
            }
        });
    },
    onReachBottom: function() {
        if (this.data.mygd != 1) {
            this.GetStoreAssessList();
        }
    },
    // 图片预览
    imgYu: function(event) {
        var src = event.currentTarget.dataset.src, //获取data-src
            imgList = event.currentTarget.dataset.list, //获取data-list
            i_url = event.currentTarget.dataset.url,
            new_imgList = []
        for (var i = 0; i < imgList.length; i++) {
            new_imgList.push(i_url + imgList[i]);
        }
        wx.previewImage({
            current: src, // 当前显示图片的http链接
            urls: new_imgList // 需要预览的图片http链接列表
        })
    },
    isshow_mask: function(e) {
        var plid = e.currentTarget.dataset.id;
        if (plid) {
            this.setData({
                plid: plid
            });
        }
        this.setData({
            is_show_hf: !this.data.is_show_hf
        });
    },

    //获取输入的内容
    getContent: function(e) {
        this.setData({
            plContent: e.detail.value || ''
        });
    },
    ToAssess: function() {
        var a = this,
            e = wx.getStorageSync("sjdsjid"),
            pl_con = a.data.plContent || '';
        if (pl_con == '') {
            wx.showToast({
                icon: "none",
                title: "请输入评论内容"
            });
            return false;
        }
        app.util.request({
            url: "entry/wxapp/ToAssess",
            cachetime: "0",
            data: {
                store_id: e,
                id: a.data.plid,
                con: pl_con
            },
            success: function(t) {
                a.setData({
                    is_show_hf: !a.data.is_show_hf
                });
                wx.showToast({
                    title: "操作成功"
                });
                setTimeout(function() {
                    a.setData({
                        page: 1,
                        order_list: [],
                    });
                    a.GetStoreAssessList();
                }, 1e3);
            }
        });
    },
    onLoad: function(t) {
        app.setNavigationBarColor(this);
        this.GetStoreAssessList();
    },
});